package com.sample.tdf.domain;

import cn.com.taiji.common.base.IBaseRepository;
import cn.com.taiji.common.base.IBaseTreeRepository;
import com.sample.tdf.dto.StaffDepartDTO;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface DepartmentRepository extends IBaseRepository<Department>, IBaseTreeRepository<Department> {

    String jpsql= " FROM Department t1 LEFT JOIN StaffDepartRelation t2 ON t1.id = t2.dId LEFT JOIN Staff t3 ON t2.sId = t3.id";
    @Query(value = "SELECT new com.sample.tdf.dto.StaffDepartDTO(t1.id, t1.parentId,t1.departName ,t3.id,t3.name)"+jpsql)
    List<StaffDepartDTO> findAllStaffDepartDTO();
}
